// 调用数据接口
+ function() {
    var CommonSucceed = AjaxComplete(3);
    // 解析标识代码
    if (GetUrlParam("id") && GetUrlParam("code")) {
        if (GetUrlParam("appraise") && GetUrlParam("appraise") == "appraise") {
            $(".common_main .common_content.event").hide();
            $(".common_main .common_content.grade").show();
        }
        var thisid = GetUrlParam("id"),
            thiscode = GetUrlParam("code");
        $(".event_flow .print h2").html(thiscode);
        $(".common_main_bread .activate").html("事件单 " + thiscode);
        // 获取事件流程
        RequestGTMC("listActionById", {
                id: thisid
            },
            function(json) {
                console.log("事件流程 获取成功");
                console.log(json);
                var sub, arr, now = 1, str = "", $el = $("#event_flow_map"), link;
                /*if (thiscode.indexOf("GT-R") > -1) {
                    console.log("属于事件单", thiscode, thiscode.indexOf("GT-R"));
                    arr = ['需求提交', '接单', 'IS部审核', '采购中', '采购完成', '一线派单', '二线响应', '二线处理', '结束'];
                } else {
                    console.log("属于事件单", thiscode, thiscode.indexOf("GT-R"));
                    arr = ['事件提交', '一线分派', '二线响应', '二线处理', '结束'];
                }
                if (json.length !== 0) {
                }
                else {
                    $(".common_main").html('<div class="common_none event">暂无任何相关记录</div>');
                    $(".common_main").css('height', document.body.clientHeight - $(".common_head").height() - 108);
                    $(".common_float").css('bottom', document.body.clientHeight - $(".common_foot").offset().top + 38);
                }
                for (sub = 0; sub < json.length; sub++) {
                    if (arr.indexOf(json[sub].action) > 0 && now - 1 < arr.indexOf(json[sub].action)) {
                        now = arr.indexOf(json[sub].action) + 1;
                    }
                }
                console.log("流程进度 " + now);
                if (now !== arr.length) {
                    str += '<div class="print"><h1>编号:<br />' + thiscode + '</h1><h2></h2><h3>处理中</h3><a href="javascript:window.print()" id="printform">打印事件</a></div>';
                } else {
                    str += '<div class="print"><h1>编号:<br />' + thiscode + '</h1><h2></h2><h3>完成</h3><a href="javascript:window.print()" id="printform">打印事件</a></div>';
                }
                if (thiscode.indexOf("GT-R") > -1) {
                    str += '<ul class="view short">';
                    for (sub = 1; sub <= arr.length; sub++) {
                        if (sub === 1) {
                            str += '<li class="out first"><span><div class="icon"><img src="../images/itsf_event_ico' + sub + 'off.png"><img src="../images/itsf_event_ico' + sub + 'out.png"><img src="../images/itsf_event_ico' + sub + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        } else if (sub < now) {
                            str += '<li class="oldgap"></li><li class="out"><span><div class="icon"><img src="../images/itsf_event_ico' + sub + 'off.png"><img src="../images/itsf_event_ico' + sub + 'out.png"><img src="../images/itsf_event_ico' + sub + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        } else if (sub === now) {
                            str += '<li class="oldgap"></li><li class="activate"><span><div class="icon"><img src="../images/itsf_event_ico' + sub + 'off.png"><img src="../images/itsf_event_ico' + sub + 'out.png"><img src="../images/itsf_event_ico' + sub + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        } else {
                            str += '<li class="pregap"></li><li><span><div class="icon"><img src="../images/itsf_event_ico' + sub + 'off.png"><img src="../images/itsf_event_ico' + sub + 'out.png"><img src="../images/itsf_event_ico' + sub + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        }
                    }
                    str += '</ul>';
                } else {
                    str += '<ul class="view">';
                    for (sub = 1; sub <= arr.length; sub++) {
                        if (sub === 1) {
                            str += '<li class="out first"><span><div class="icon"><img src="../images/itsf_event_ico' + sub + 'off.png"><img src="../images/itsf_event_ico' + sub + 'out.png"><img src="../images/itsf_event_ico' + sub + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        } else if (sub < now) {
                            str += '<li class="oldgap"></li><li class="out"><span><div class="icon"><img src="../images/itsf_event_ico' + (sub + 4) + 'off.png"><img src="images/itsf_event_ico' + (sub + 4) + 'out.png"><img src="images/itsf_event_ico' + (sub + 4) + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        } else if (sub === now) {
                            str += '<li class="oldgap"></li><li class="activate"><span><div class="icon"><img src="../images/itsf_event_ico' + (sub + 4) + 'off.png"><img src="../images/itsf_event_ico' + (sub + 4) + 'out.png"><img src="../images/itsf_event_ico' + (sub + 4) + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        } else {
                            str += '<li class="pregap"></li><li><span><div class="icon"><img src="../images/itsf_event_ico' + (sub + 4) + 'off.png"><img src="../images/itsf_event_ico' + (sub + 4) + 'out.png"><img src="../images/itsf_event_ico' + (sub + 4) + 'act.png"></div><p>' + arr[sub - 1] + '</p></span></li> ';
                        }
                    }
                    str += '</ul>';
                }*/
                if (json&&json.length>0) {
                    for (sub = 0; sub < json.length; sub++) {
                        if (json[sub].status === "1") {
                            str = json[sub].action;
                        }
                    }
                    str = '<div class="print"><h1>编号:<br />' + thiscode + '</h1><h2></h2><h3>' + str + '</h3><a href="javascript:window.print()" id="printform">打印事件</a></div><ul class="view">';
                    for (sub = 0; sub < json.length; sub++) {
                        if (sub === 0) {
                            // 第一个
                            if (json[sub].status === "1") {
                            str += '<li class="first activate"><span><div class="icon"><img src="' + ITSMLINK + json[sub].offSrc + '"><img src="' + ITSMLINK + json[sub].outSrc + '"><img src="' + ITSMLINK + json[sub].actSrc + '"></div><p>' + json[sub].action + '</p>' + (json[sub].actionTime?'<p>' + json[sub].actionTime.split(" ")[0].replace(/-/g,"/") + '</p><p>' + json[sub].actionTime.split(" ")[1] + '</p>':'') + '</span></li> ';
                            } else {
                            str += '<li class="out first"><span><div class="icon"><img src="' + ITSMLINK + json[sub].offSrc + '"><img src="' + ITSMLINK + json[sub].outSrc + '"><img src="' + ITSMLINK + json[sub].actSrc + '"></div><p>' + json[sub].action + '</p>' + (json[sub].actionTime?'<p>' + json[sub].actionTime.split(" ")[0].replace(/-/g,"/") + '</p><p>' + json[sub].actionTime.split(" ")[1] + '</p>':'') + '</span></li> ';
                            }
                        } else if (json[sub].status === "1") {
                            // 正处理
                            str += '<li class="oldgap"></li><li class="activate"><span><div class="icon"><img src="' + ITSMLINK + json[sub].offSrc + '"><img src="' + ITSMLINK + json[sub].outSrc + '"><img src="' + ITSMLINK + json[sub].actSrc + '"></div><p>' + json[sub].action + '</p>' + (json[sub].actionTime?'<p>' + json[sub].actionTime.split(" ")[0].replace(/-/g,"/") + '</p><p>' + json[sub].actionTime.split(" ")[1] + '</p>':'') + '</span></li>';
                        } else if (json[sub].status === "0") {
                            // 已处理
                            str += '<li class="oldgap"></li><li class="out"><span><div class="icon"><img src="' + ITSMLINK + json[sub].offSrc + '"><img src="' + ITSMLINK + json[sub].outSrc + '"><img src="' + ITSMLINK + json[sub].actSrc + '"></div><p>' + json[sub].action + '</p>' + (json[sub].actionTime?'<p>' + json[sub].actionTime.split(" ")[0].replace(/-/g,"/") + '</p><p>' + json[sub].actionTime.split(" ")[1] + '</p>':'') + '</span></li> ';
                        } else if (json[sub].status === "-1") {
                            // 未处理
                            str += '<li class="pregap"></li><li><span><div class="icon"><img src="' + ITSMLINK + json[sub].offSrc + '"><img src="' + ITSMLINK + json[sub].outSrc + '"><img src="' + ITSMLINK + json[sub].actSrc + '"></div><p>' + json[sub].action + '</p></span></li> ';
                        }
                    }
                    str += '</ul>';
                    $el.html(str);
                } else {
                    $el.remove();
                }
            },
            function() {
                console.log("事件流程 调用失败");
            },
            function() {
                console.log("事件流程 请求完成");
                // 获取事件详情
                RequestGTMC("listIcdInfoById", {
                    id: thisid
                },
                function(data) {
                    console.log("事件详情 获取成功");
                    console.log(data);
                    if (data) {
                        var sub, arr, now = 1, str = "", $el = $("#event_flow_map"), link;
                        // 判断打印
                        if (data.request_id && data.request_id !== "0") {
                            var link = GetPrintLink(data.type_code, data.request_id);
                            console.log("有打印", data.type_code, data.request_id, link);
                            $("#printform").attr('href', link);
                        } else {
                            $("#printform").remove();
                        }
                        str = '<li class="part"><span class="caption">申报人信息</span><div class="line"><span>申&ensp;报&ensp;人：</span><span>'
                        + (data.cususer && data.cususer.fullname ? data.cususer.fullname : '') + (data.cususer && data.cususer.name ? '（工号 '+ data.cususer.name + '）' : '')
                        + '</span></div><div class="line"><span>用户类型：</span><span>'
                        + (data.cususer && data.cususer.type ? data.cususer.type : '')
                        + '</span></div><div class="line"><span>所在部门：</span><span>'
                        + (data.cususer && data.cususer.departmentTreenodeNamePath ? data.cususer.departmentTreenodeNamePath /*.split("/").join(" ")*/ : '')
                        + '</span></div><div class="line"><span>联&ensp;系&ensp;人：</span>'
                        + (data.linkman_name ? '<span>' + data.linkman_name + '</span>' : '')
                        + '</div><div class="line"><span>联系电话：</span>'
                        + (data.linkman_phone ? '<span>' + data.linkman_phone + '</span>' : '')
                        + '</div><div class="line"><span>短&emsp;&emsp;号：</span><span>'
                        + (data.cususer && data.cususer.mobileShort ? data.cususer.mobileShort : '')
                        + '</span></div><div class="line"><span>邮&emsp;&emsp;件：</span><span>'
                        + (data.cususer && data.cususer.email ? data.cususer.email : '')
                        + '</span></div></li><li class="part file"><span class="caption">事件信息</span><div class="line"><span>事件单号：</span>'
                        + (data.code ? '<span>' + data.code + '</span>' : '')
                        + '</div><div class="line"><span>事件标题：</span>'
                        + (data.title ? '<span>' + data.title + '</span>' : '')
                        + '</div><div class="line"><span>创建时间：</span>'
                        + (data.create_date ? '<span>' + data.create_date + '</span>' : '')
                        + '</div><div class="line">';
                        if (data.incident_type && data.incident_type === "需求" && data.code.indexOf("GT-R") > -1) {
                            str += '<span>事件描述：</span>' + (data.description ? '<span>' + data.description.replace(/\n/g,"<br>") + '</span>' : '')
                        } else {
                            str += '<span>事件描述：</span>' + (data.description ? '<span>' + data.description + '</span>' : '');
                        }
                        str += '</div>' + (data.ci_code ? '<div class="line"><span>关联设备：</span><span>' + data.ci_code + '</span></div>' : '')
                        + (data.status === "已关闭" ? '' : '<div class="line common_file_upload"><span>附件上传：</span><span><a href="javascript:" class="upload_sel">选择附件<input id="fileupload" type="file" multiple></a><ul class="upload_list"></ul><div class="upload_up">点击上传</div><span class="upload_tips">支持格式：<br />jpg,gif,png,jpeg,txt,doc,docx,xls,xlsx,ppt,pptx,pdf,zip,rar,apk,msg,eml,csv,tif</span></span></div>') + '</li><li class="part"><span class="caption">服务承诺'
                        + (data.slm_name ? '<em>（' + data.slm_name + '）</em>' : '')
                        + '</span><div class="duration"><span class="l1">响应时长：</span><span class="l2">目标时长</span><span class="l3">'
                        + (data.objective_accept_timecost || '')
                        + '</span><span class="l2">已用时长'
                        + (data.accept_status ? '（<em class="' + (data.accept_status==="正常"?'green':'orange') + '">' + data.accept_status + '</em>）' : '')
                        + '</span><span class="l3"><em class="' + (data.accept_status==="正常"?'green':'orange') + '">'
                        + (data.accept_timecost || '')
                        + '</em></span></div><div class="duration"><span class="l1">对应时长：</span><span class="l2">目标时长</span><span class="l3">'
                        + (data.objective_timecost || '')
                        + '</span><span class="l2">已用时长'
                        + (data.solve_status ? '（<em class="' + (data.solve_status==="正常"?'green':'orange') + '">' + data.solve_status + '</em>）' : '')
                        + '</span><span class="l3"><em class="' + (data.solve_status==="正常"?'green':'orange') + '">'
                        + (data.solve_timecost || '') + '</em></span></div></li>';
                        $("#event_info_line1").html(str);
                        str = '<li class="part low"><span class="caption">一线工程师</span><div><div class="portrait"><div class="icon">'
                        + (data.disuser && data.disuser.photo ? '<img src="/imgSrc?path=' + (data.disuser.photo.indexOf("itsmfile") >= 0 ? data.disuser.photo : "///itsmfile//gtmc_itsm_share//uploadFile//global" + data.disuser.photo) + '">' : '') + '</div><h1>一线分派人</h1><h2>'
                        + (data.distributor_name || '') + '</h2></div><div class="row">所属系统：</div><div class="row">'
                        + (data.icd_category_name || '') + '</div>'
                        + (data.assign_date ? '<div class="row">分派时间：</div><div class="row">' + data.assign_date + '</div>' : '') + '</div></li><li class="part low"><span class="caption">二线工程师</span><div><div class="portrait"><div class="icon">'
                        + (data.supuser && data.supuser.photo ? '<img src="/imgSrc?path=' + (data.supuser.photo.indexOf("itsmfile") >= 0 ? data.supuser.photo : "///itsmfile//gtmc_itsm_share//uploadFile//global" + data.supuser.photo) + '">' : '') + '</div><h1>二线受理人</h1><h2>'
                        + (data.supuser && data.supuser.fullname ? data.supuser.fullname : '') + '</h2></div><div class="row">所属公司：</div><div class="row">'
                        + (data.supuser && data.supuser.departmentTreenodeNamePath ? data.supuser.departmentTreenodeNamePath : '') + '</div><div class="row">邮&emsp;&emsp;箱：</div><div class="row">'
                        + (data.supuser && data.supuser.email ? data.supuser.email : '') + '</div><div class="row">电&emsp;&emsp;话：</div><div class="row">'
                        + (data.supuser && data.supuser.mobile ? data.supuser.mobile : '') + '</div><div class="row">受理时间：</div><div class="row">'
                        + (data.response_date || '') + '</div><div class="row">完成时间：</div><div class="row">'
                        + (data.solve_submit_time || '') + '</div></div></li><li class="part low last"><span class="caption">客户关闭与评价</span><div class="row"><span>关闭码：</span><span>'
                        + (data.close_code || '') + '</span></div><div class="row"><span>关闭时间：</span><span>'
                        + (data.closed_date || '') + '</span></div>';
                        if (data.solver_submit_time) {
                            console.log("评分", data.satisfaction, data.satisfaction_quality, data.satisfaction_approach, data.satisfaction_timely);
                            if (typeof(data.satisfaction) !== "undefined") {
                                str += '<div class="row"><span>满意度：</span><ol class="event_star">';
                                for (sub = 0; sub < 5; sub++) {
                                    if ((sub + 1) <= data.satisfaction) {
                                        str += '<li class="yes"></li>';
                                    } else {
                                        str += '<li></li>';
                                    }
                                }
                                str += '</ol></div>';
                            }
                            if (typeof(data.satisfaction_quality) !== "undefined") {
                                str += '<div class="row"><span>技能水平：</span><ol class="event_star">';
                                for (sub = 0; sub < 5; sub++) {
                                    if ((sub + 1) <= data.satisfaction_quality) {
                                        str += '<li class="yes"></li>';
                                    } else {
                                        str += '<li></li>';
                                    }
                                }
                                str += '</ol></div>';
                            }
                            if (typeof(data.satisfaction_approach) !== "undefined") {
                                str += '<div class="row"><span>服务态度：</span><ol class="event_star">';
                                for (sub = 0; sub < 5; sub++) {
                                    if ((sub + 1) <= data.satisfaction_approach) {
                                        str += '<li class="yes"></li>';
                                    } else {
                                        str += '<li></li>';
                                    }
                                }
                                str += '</ol></div>';
                            }
                            if (typeof(data.satisfaction_timely) !== "undefined") {
                                str += '<div class="row"><span>服务及时性：</span><ol class="event_star">';
                                for (sub = 0; sub < 5; sub++) {
                                    if ((sub + 1) <= data.satisfaction_timely) {
                                        str += '<li class="yes"></li>';
                                    } else {
                                        str += '<li></li>';
                                    }
                                }
                                str += '</ol></div>';
                            }
                            var date = new Date(data.solver_submit_time), today = new Date();
                            console.log(date, today, (today - date) / 86400000);
                            if ((today - date) / 86400000 < 14 && data.are_feedback === 0) {
                                str += '<a href="javascript:" class="review">评价</a></li>';
                                $("#event_info_line2").html(str);
                                // 评价跳转
                                $(".common_content .event_info .part").on('click', '.review', function(event) {
                                    $(".common_main .common_content.event").hide();
                                    $(".common_main .common_content.grade").show();
                                    TOPSWIPE.reInit();
                                    TOPSWIPE.swipeNext();
                                });
                            } else {
                                str += '</li>';
                                $("#event_info_line2").html(str);
                            }
                        } else {
                            str += '</li>';
                            $("#event_info_line2").html(str);
                        }
                        $(".common_content.grade .event_appraise .person:eq(0)").html('<div class="head">' + (data.disuser && data.disuser.photo ? '<img src="/imgSrc?path=' + (data.disuser.photo.indexOf("itsmfile") >= 0 ? data.disuser.photo : "///itsmfile//gtmc_itsm_share//uploadFile//global" + data.disuser.photo) + '">' : '') + '</div><span>一线分派人：<em>' + (data.distributor_name || '') + '</em></span>');
                        $(".common_content.grade .event_appraise .person:eq(1)").html('<div class="head">' + (data.supuser && data.supuser.photo ? '<img src="/imgSrc?path=' + (data.supuser.photo.indexOf("itsmfile") >= 0 ? data.supuser.photo : "///itsmfile//gtmc_itsm_share//uploadFile//global" + data.supuser.photo) + '">' : '') + '</div><span>二线受理人：<em>' + (data.supuser && data.supuser.fullname || '') + '</em></span>');
                        $(".common_content.grade .event_lowpoint .info").html('<span>事件标题：<em>' + (data.title || '') + '</em></span><span>创建时间：<em>' + (data.create_date || '') + '</em></span><span>完成时间：<em>' + (data.closed_date || '') + '</em></span><span class="long"><p>事件描述：</p><em>' + (data.description || '') + '</em></span>');
                    } else {
                        $("#event_info_line1").empty();
                        $("#event_info_line2").empty();
                    }
                    // 获取资源标识
                    RequestGTMC("getSourceIdByCode", {id: thisid, code: thiscode},
                        function(json) {
                            console.log("资源标识 获取成功");
                            console.log(json);
                            if (json && json.data) {
                                var thissource = json.data;
                                // 获取文件下载
                                RequestGTMC("listUploadBySourceId", {sourceId:thissource},
                                    function(json) {
                                        console.log("下载列表 获取成功");
                                        console.log(json);
                                        if (json && json.length > 0) {
                                            var str = '<div class="line"><span>附件下载：</span><span>';
                                            for (var i = 0; i < json.length; i++) {
                                                str += '<a class="download" href="' + ITSMLINK + 'fileDownload?id=' + json[i].id + '">' + json[i].name + '</a>'
                                            }
                                            str += '</span></div>';
                                            console.log($el, str);
                                            $(".common_file_upload").before(str);
                                        }
                                        AddDoneCount();
                                    },
                                    function() {
                                        console.log("下载列表 调用失败");
                                    },
                                    function() {
                                        console.log("下载列表 请求完成");
                                    }
                                );
                                // 绑定上传事件
                                UploadEvent(thissource);
                            }
                            AddDoneCount();
                        },
                        function() {
                            console.log("资源标识 调用失败");
                        },
                        function() {
                            console.log("资源标识 请求完成");
                        }
                    );
                },
                function() {
                    console.log("事件详情 调用失败");
                },
                function() {
                    console.log("事件详情 请求完成");
                });
                AddDoneCount();
            });
    } else {
        $(".common_main").html('<div class="common_none event">暂无任何相关记录</div>');
        $(".common_main").css('height', document.body.clientHeight - $(".common_head").height() - 108);
        $(".common_float").css('bottom', document.body.clientHeight - $(".common_foot").offset().top + 38);
    }
}();

// 上传附件
function UploadEvent (itemid) {
    var namelist = new Array(), acceptFileTypes = /(jpg|gif|png|jpeg|txt|doc|docx|xls|xlsx|ppt|pptx|pdf|zip|rar|apk|msg|eml|csv|tif)$/i;
    $("#fileupload").fileupload({
        url: ITSMLINK + 'fileUpload?sourceId=' + itemid,
        bitrateInterval: 100,
        autoUpload: false,
        dataType: "json",
        add: function (e, data) {
            // 去重名
            if (namelist.indexOf(data.files[0].name) === -1) {
                // 限格式
                if (acceptFileTypes.test(data.files[0].name.split(".")[data.files[0].name.split(".").length - 1])) {
                    // 限大小
                    if (data.originalFiles[0]['size'] < 15728640) {
                        $(".common_file_upload .upload_list").addClass('activate').append('<li><span class="act">' + data.files[0].name + '</span></li>');
                        $("<a/>").appendTo($(".common_file_upload .upload_list li:last")).attr({
                            "href": "javascript:",
                            "class": "del"
                        }).on('click', function(event) {
                            var arrindex = $(this).parent().index();
                            namelist.splice(arrindex, 1);
                            $(this).parent().remove();
                            console.log(namelist, e, data);
                        });
                        $("<a/>").appendTo($(".common_file_upload .upload_list li:last")).attr({
                            "href": "javascript:",
                            "class": "hid"
                        }).on('click', function(event) {
                            data.submit();
                            $(this).siblings('.del').remove();
                            $(this).remove();
                        });
                        $("<div/>").appendTo($(".common_file_upload .upload_list li:last")).addClass('progressline');
                        namelist.push(data.files[0].name);
                    } else {
                        $(".common_shadow").addClass('activate').children('.event_popup_report').addClass('activate rule').find('.word').html("请核对上传文件大小是否超过 15M 。");
                    }
                } else {
                    $(".common_shadow").addClass('activate').children('.event_popup_report').addClass('activate rule').find('.word').html("请核对上传文件格式是否符合。");
                }
            } else {
                $(".common_shadow").addClass('activate').children('.event_popup_report').addClass('activate rule').find('.word').html("请核对上传文件名称是否相同。");
            }
            console.log(namelist, e, data);
            console.log(data.originalFiles[0]['size'], (data.originalFiles[0]['size'] < 15728640), data.files[0].name.split(".")[data.files[0].name.split(".").length - 1], acceptFileTypes.test(data.files[0].name.split(".")[data.files[0].name.split(".").length - 1]), data.files[0].name.split(".").length, data.originalFiles[0]['type']);
        },
        done: function (e, data) {
            console.log("done", namelist.indexOf(data.files[0].name), e, data);
            $(".common_file_upload .upload_list .progressline").eq(namelist.indexOf(data.files[0].name)).css('width', 100 + '%').before('<div class="yes"></div>');
        },
        progress: function (e, data) {
            console.log('progress', namelist.indexOf(data.files[0].name), e, data);
            $(".common_file_upload .upload_list .progressline").eq(namelist.indexOf(data.files[0].name)).css('width', parseInt(data.loaded / data.total * 100, 10) + '%');
        },
        progressall: function (e, data) {
            console.log(data.loaded + "/" + data.total, data.loaded === data.total);
        },
        completed: function (e, data) {
            console.log(completed);
        }
    });
    $(".common_file_upload .upload_up").on('click', function(event) {
        $(".common_file_upload .upload_list .hid").trigger('click');
    });
}

// 事件绑定
- function() {
    // 评价结束
    $(".common_content.grade .twobtn .refer").on('click', function(event) {
        $(".common_shadow").addClass('activate').children('.event_popup_report').addClass('activate').find('.word').html("您的评价正在提交中。");
        var grade = new Array(4), thisid = GetUrlParam("id");
        grade[0] = $(".common_content.grade .grade em").html().split("分")[0];
        $(".common_content.grade .mark em").each(function(index, el) {
            grade[index + 1] = $(this).html().split("分")[0];
            console.log(grade, index, el);
        });
        RequestGTMC("icdSatisfactionSubmit", {
            id: thisid,
            satisfaction: grade[0],
            satisfactionQuality: grade[1],
            satisfactionApproach: grade[2],
            satisfactionTimely: grade[3],
            customerOpinion: $(".event_lowpoint .excuse textarea").val()
        },
        function(data) {
            console.log("提交评价成功");
            console.log(data);
            RequestGTMC("listIcdInfoById", {id: thisid}, function (json) {
                console.log("更新评价 获取成功");
                console.log(json);
                if (json.solver_submit_time) {
                    var str = '<span class="caption">客户关闭与评价</span><div class="row"><span>关闭码：</span><span>'
                        + (json.close_code || '') + '</span></div><div class="row"><span>关闭时间：</span><span>'
                        + (json.closed_date || '') + '</span></div>';
                    console.log("评分", json.satisfaction, json.satisfaction_quality, json.satisfaction_approach, json.satisfaction_timely);
                    if (typeof(json.satisfaction) !== "undefined") {
                        str += '<div class="row"><span>满意度：</span><ol class="event_star">';
                        for (sub = 0; sub < 5; sub++) {
                            if ((sub + 1) <= json.satisfaction) {
                                str += '<li class="yes"></li>';
                            } else {
                                str += '<li></li>';
                            }
                        }
                        str += '</ol></div>';
                    }
                    if (typeof(json.satisfaction_quality) !== "undefined") {
                        str += '<div class="row"><span>技能水平：</span><ol class="event_star">';
                        for (sub = 0; sub < 5; sub++) {
                            if ((sub + 1) <= json.satisfaction_quality) {
                                str += '<li class="yes"></li>';
                            } else {
                                str += '<li></li>';
                            }
                        }
                        str += '</ol></div>';
                    }
                    if (typeof(json.satisfaction_approach) !== "undefined") {
                        str += '<div class="row"><span>服务态度：</span><ol class="event_star">';
                        for (sub = 0; sub < 5; sub++) {
                            if ((sub + 1) <= json.satisfaction_approach) {
                                str += '<li class="yes"></li>';
                            } else {
                                str += '<li></li>';
                            }
                        }
                        str += '</ol></div>';
                    }
                    if (typeof(json.satisfaction_timely) !== "undefined") {
                        str += '<div class="row"><span>服务及时性：</span><ol class="event_star">';
                        for (sub = 0; sub < 5; sub++) {
                            if ((sub + 1) <= json.satisfaction_timely) {
                                str += '<li class="yes"></li>';
                            } else {
                                str += '<li></li>';
                            }
                        }
                        str += '</ol></div>';
                    }
                    $("#event_info_line2 .part.low.last").html(str);
                    $(".common_shadow .event_popup_report").addClass('done').find('.word').html('您的评价已经提交完成。');
                }
            });
        },
        function() {
            console.log("提交评价失败");
        },
        function() {
            console.log("提交评价完成");
        });
        /*$(".common_main .common_content.event").removeAttr('style');
        $(".common_main .common_content.grade").removeAttr('style');
        TOPSWIPE.reInit();
        TOPSWIPE.swipeNext();*/
    });
    // 满意评星
    $(".common_content .event_star li").on('mouseover', function(event) {
        var last = $(this).index();
        if (!$(this).hasClass('yes')) {
            $(this).parent().children().each(function(index, el) {
                if (index <= last) {
                    // console.log($(this));
                    $(this).addClass('yes');
                }
            });
        } else {
            $(this).parent().children().each(function(index, el) {
                if (index > last) {
                    // console.log($(this));
                    $(this).removeAttr('class');
                }
            });
        }
        $(this).parent().siblings('em').html(++last + "分");
    });
    $(".common_content .event_star li").on('mouseout', function(event) {
        $(this).removeAttr('class').siblings('li').removeAttr('class');
        $(this).parent().siblings('em').html("0分");
    });
    $(".common_content .event_star li").on('click', function(event) {
        $(this).parent().children('li').off('mouseover mouseout');
        var last = $(this).index();
        if (!$(this).hasClass('yes')) {
            $(this).parent().children().each(function(index, el) {
                if (index <= last) {
                    // console.log($(this));
                    $(this).addClass('yes');
                }
            });
        } else {
            $(this).parent().children().each(function(index, el) {
                if (index > last) {
                    // console.log($(this));
                    $(this).removeAttr('class');
                }
            });
        }
        if ($(this).parent().parent().hasClass('grade')) {
            if (last < 2) {
                $(".common_content.grade .event_lowpoint .bad").css('display', 'inline-block');
            } else {
                $(".common_content.grade .event_lowpoint .bad").removeAttr('style');
            }
        }
        $(this).parent().siblings('em').html(++last + "分");
    });
    // 重置选项
    $(".common_main .common_content.grade .twobtn").on('click', '.reset', function(event) {
        $(".common_content.grade .event_star li").removeClass('yes');
        $(".common_content.grade .grade em").html('0分');
        $(".common_content.grade .detail em").html('0分');
        $(".common_content.grade .event_lowpoint .bad").css('display', 'inline-block');
        console.log($(".common_content.grade .event_lowpoint textarea"));
        $(".common_content.grade .event_lowpoint textarea").val("");
    });
    console.log("clientHeight : " + document.body.clientHeight + ", offsetHeight : " + document.body.offsetHeight + ", scrollHeight : " + document.body.scrollHeight);
    // 中间高度撑开
    if (document.body.clientHeight >= document.body.scrollHeight) {
        console.log("clientHeight : " + document.body.clientHeight + ", offsetHeight : " + document.body.offsetHeight + ", common_head : " + $(".common_head").height());
        // $(".common_main").css('min-height', document.body.clientHeight - $(".common_head").height() - 108);
        $(".common_float").css('bottom', document.body.clientHeight - $(".common_foot").offset().top + 38);
    }
    // 提交后返回
    $(".event_popup_report .back a").on('click', function(event) {
            $(".event_popup_report").removeClass('activate done rule').parent().removeClass('activate');
            $(".common_main .common_content.event").removeAttr('style');
            $(".common_main .common_content.grade").removeAttr('style');
            TOPSWIPE.reInit();
            TOPSWIPE.swipeNext();
            $(".event_info .part .review").hide();
    });
}();